#{extends 'common/frontMain.html' /}
#{set title:'通过手机找回用户名' /}
<div class="xf_login_centent clr">
			<div class="xf_register_email">
				<ul class="xf_register_email_ul clr" id="xf_wyjkview_xxk">
					<li  id="findByEamil" onClick="pageEmail()">邮箱找回用户名</li>
					<li class="xf_con_wyjk_r_liishot xf_con_wyjk_r_liwyhm" id="findBytele">手机找回用户名</li>
				</ul>
				#{form @saveUsernameByTele(), id:'teleSubmit'}
				<div class="xf_con_wyjk_tentultbody" id="telephoneDiv">
					<ul class="xf_login_inputsrul xf_login_inputsrul_zhyhm">
						<li>
							<div class="xf_login_inputsrul_l xf_login_inputsrul_lyhm">请输入您绑定的手机号码：</div>
							<div class="xf_login_inputsrul_r">
							<input class="xf_login_shurk" type="text" id="telephone" name="mobile" value="${flash?.mobile}">
							<span class="xf_register_intext" id="s_telephone"></span></div>
						</li>
						<li>
							<div class="xf_login_inputsrul_l xf_login_inputsrul_lyhm">验证码：</div>
							<div class="xf_login_inputsrul_r">
							<input class="xf_login_yzm" type="text" name="code" id="code" value="${flash.code}">
							<input type="hidden" name="randomID" id="randomID" />
							<img src="images/xf_yzm.jpg" onClick="change()" class="xf_login_yzmimg" id="img" width="75px" height="28px">
							<a href="javascript:void(0);" onClick="change()" class="xf_login_inputspan">刷新</a>
							<span class="xf_register_intext" id="s_teleCode"></span>
							</div>
						</li>
						<li>
							<div class="xf_login_inputsrul_l xf_login_inputsrul_lyhm">&nbsp;</div>
							<div class="xf_login_inputsrul_r">
								<a onClick="teleSubmit()" class="xf_con_inputfbjk">确定</a>
							</div>
						</li>
					</ul>
				</div>
				#{/form}
			</div>
		</div>
		<!-- 底部阴影 -->
<div class="xf_login_kjyy"></div>
<script type="text/javascript">
  /* $(document).keyup(function(event){
			  if(event.keyCode == 13){
			     teleSubmit();
			 }
		});
*/
    $(function(){
         var setCode = #{jsAction @setCode()/}
		 $.post(setCode({}),function(data){
			var arr=eval(data);
			var img = arr.img;
			$("#img").attr("src","@{getImg()}?id="+img);	
			$("#randomID").val(img);
		 });
      })
 /*   
    function teleCode(){
		var setCode = #{jsAction @setCode()/}
		$.post(setCode({}),function(data){
		var arr=eval(data);
		var img = arr.img;
		$("#teleImg").attr("src","@{getImg()}?id="+img)	
		$("#teleCode").val(img);
	  });
	}

     var blugCode = false;
     $(document).ready(function(){
        $("#teleRandomID").blur(function(){ 
	       if(this.value == ""){
	           $("#s_teleCode").html("验证码不能为空");
	           return;
		 }else{
	        var listAction = #{jsAction @front.account.LoginAndRegisterAction.codeReturn(':codeImg') /};
	   		var codeImg =  $("#teleCode").val();
	   		$.post(listAction({codeImg:codeImg}), function(data) {
	   			var arr = eval(data);
				var results = arr.randomID;
				var code = $("#teleRandomID").val();
	   			if(results.toLowerCase() != code.toLowerCase()){
			           $("#s_teleCode").html("验证码输入错误");
			           blugCode = true;
				}else{ 
		               $("#s_teleCode").html(""); 
		               blugCode = false;
		          }
	   		});		
		   }
       });
     });
  */  
    function teleSubmit(){
        if($("#telephone").val() == ""){
            alert("请输入手机号码");
            return;
            
        }  
     
        if($("code").val() == ''){
            alert("请输入验证码");
            return;
        }
        
        if(!$("#telephone").val().isMobileNum()) {
        	alert("请输入正确的手机号码");
            return;
        } 
     /*   
        if(teleBlug == true){
            $("#s_telephone").html("");
            $("#s_telephone").html("该手机不存在");
            location.reload();
            return;
        }
        
        if(blugCode == true){
        	$("#s_telephone").html("");
        	$("#s_telephone").html("验证码输入错误");
        	location.reload();
        	return;
        }
     */   
        $("#teleSubmit").submit();
    }
   /* 
     var teleBlug = false;
     $(document).ready(function(){
       $("#telephone").blur(function(){ 
	     if(this.value == ""){
	           $("#s_telephone").html("手机不能为空");
	           return;
		 }else{
	     var hasMobileExist = #{jsAction @hasMobileExist(':telephone')/}
		 $.post(hasMobileExist({telephone:$("#telephone").val()}),function(data){
			 var arr=eval(data);
			 var results = arr.result;
			 if(results == 0){
		           $("#s_telephone").html("该手机不存在");
		           teleBlug = true;
			}else{ 
	               $("#s_telephone").html(""); 
	               teleBlug = false;
	            }
	          });
		   }
       });
      });
  */     
    function pageEmail(){
        window.location.href = "@{findBackUsernameByEmail()}";
    }
</script>